<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
${aier_doctype}
<html <s:property value="aier-html-xmlns" escape="false"/>>
<head>
<meta http-equiv="Content-Type" content="${aier_content_type}" />
<meta name="keywords" content="${aier_keyworks}" />
<meta name="description" content="${aier_description}" />
<title>${aier_title}</title>
<link rel="stylesheet" href="${aier_css_url}${aier_jqui_css}ui.css" />
<link rel="Stylesheet" href="${aier_css_url}jq/jq.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/jq-msg.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/reset.css" />
<link rel="stylesheet"
	href="${aier_css_url}social/user/accountSettings/common.css" />
<link rel="stylesheet"
	href="${aier_css_url}social/user/accountSettings/pi.css" />

<script type="text/javascript" src="${aier_js_url}j.js"></script>
<script type="text/javascript" src="${aier_js_url}b.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/hh/ui.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/msg.js"></script>

<script type="text/javascript" src="${aier_js_url}97/WdatePicker.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/cn.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/jq.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/block.js"></script>
</head>
<!-- 个人基本资料页面 -->
<body>
	<!-- 顶栏 -->
	<s:action name="userhomecomm_homeHead" namespace="/user"
		executeResult="true"></s:action>

	<!-- 正文 -->
	<div id="hfContent" class="ar-content">
		<div class="content-main">
			<div class="main-content wrap-bg clearfix">
				<!-- 左侧栏 -->
				<s:action name="useraccountsettings_aSettingsLeft" namespace="/user"
					executeResult="true"></s:action>
				<!-- 右侧内容 -->
				<div class="ae-right">
					<div class="right-main">
						<div class="right-main-top">
							<div class="binfo-title">
								<h3>基本信息</h3>
							</div>
							<div class="right-line"></div>
						</div>
						<div class="right-main-c">
							<div class="info-tab01">
								<table>
									<tr>
										<th class="gray6 "><div class="t-th-width">账号：</div></th>
										<td class="font-12"><em>${user.account}</em></td>

									</tr>
									<tr>
										<th class="gray6 t-th-width">昵称：</th>
										<td><input type="text" maxlength="50" class="PY-input"
											name="nickName" value="${user.nickname}" id="nickName">
										</td>
									</tr>
									<tr>
										<th class="gray6 t-th-width">真实姓名：</th>
										<td><input type="text" maxlength="50" class="PY-input"
											name="realName" value="${user.realname}" id="realName">
										</td>
									</tr>
									<tr>
										<th class="gray6 t-th-width">出生日期：</th>
										<td class="info-tab-vm"><input type="text" id="birthday"
											class="PY-input" readonly="readonly"
											onfocus="WdatePicker({skin:'twoer',dateFmt:'yyyy-MM-dd',readOnly:true})">
										</td>
									</tr>
									<tr>
										<th class="gray6 t-th-width">所在地：</th>
										<td class="info-tab-vm"><s:action name="citiesmap_cc1"
												namespace="/common" executeResult="true"></s:action>
										</td>
									</tr>
									<tr>
										<th class="gray6 t-th-width">性别：</th>
										<td class="info-tab-vm"><input id="man" name="gender"
											type="radio" value="m" class="info-radio01"> <label
											for="man">男</label> <input id="woman" name="gender"
											type="radio" value="f" class="info-radio01"> <label
											for="woman">女</label>
										</td>
									</tr>
									<tr>
										<th class="gray6 t-th-width" align="left" valign="top">个性签名：</th>
										<td class="info-tab-vm"><textarea onkeyup="wordsDeal();"
												style="width: 220px;height: 150px;border: 1px solid #ccc;resize: none;"
												id="desinfo">${user.desinfo}</textarea>
											<p id="textCount">
											</p>
										</td>
									</tr>
									<tr>
										<th></th>
										<td>
											<div class="mib-btn" onclick="upinfo()"></div>
										</td>
									</tr>
								</table>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<!-- footer copyright -->
		<s:action name="userhomecomm_homeFooter" namespace="/user"
			executeResult="true"></s:action>
		<!-- /footer copyright -->
	</div>

</body>
<script type="text/javascript">
	$("#tabs").tabs();

	//个人简介输入框剩余字数
	function wordsDeal() {
		//var curLength = $("#desinfo").val().length;
		//if (curLength > 100) {
		//var num = $("#desinfo").val().substr(0, 100);
		//$("#desinfo").val(num);
		//	$().message("超过字数限制，多出的字将被截断！");
		//} else {
		//	$("#textCount").text(100 - $("#desinfo").val().length);
		//}

	}
	$("#desinfo").live("input", function() {
		var curLength = $("#desinfo").val().length;

		if (curLength > 100) {
			//var num = $("#desinfo").val().substr(0, 100);
			//$("#desinfo").val(num);
			var le = $("#desinfo").val().length-100;
			$("#textCount").html("<span style='color:#E44443;font-size: 12px;'>已超出"+le+"个字</span>");//剩余字数
		} else {
			var le = 100 - $("#desinfo").val().length;
			$("#textCount").html("<span style='font-size: 12px;'>还可以输入"+le+"个字</span>");//剩余字数
		}
	});

	$(document).ready(function() {
		$('#birthday').val("${user.birthday}");
		if ("男" == "${user.sex}") {
			$("#man").attr("checked", true);
		} else {
			$("#woman").attr("checked", true);
		}
	});

	// 修改个人信息
	function upinfo() {
		var pid = $("#province").val(), cid = $("#city").val(), did = $("#area")
				.val(), sid = $("#street").val(), nickName = $("#nickName")
				.val();
		var areaId = sid != -1 ? sid : did != -1 ? did : cid != -1 ? cid : pid;
		if (isnull(nickName) || "" == nickName.trim()) {
			$().message("昵称不能为空！");
			return;
		}
		if($("#desinfo").val().length>100){
			$().message("个人简介超过字数限制！");
			return;
		}
		if ($('#man').attr("checked") == "checked") {
			var sex = "男";
		} else {
			var sex = "女";
		}
		var fun = function(data) {
			if (1 == data.s) {
				$().message("修改成功!");
			} else {
				$().message("修改失败!" + data.error_info);
			}
		};
		exeAjax(
				ajaxUrl("${aier_url}${aier_urijs}useraccountsettings_updateUserInfo${aier_suffix}"),
				fun, {
					"nickname" : $("#nickName").val(),
					"realname" : $("#realName").val(),
					"sex" : sex,
					"city_id" : areaId,
					"desinfo" : $("#desinfo").val(),
					"birthday" : $('#birthday').val()
				});
	}
</script>

</html>